package com.whc.service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.whc.common.Constant;
import com.whc.common.Context;
import com.whc.common.exception.MessageException;
import com.whc.mapper.CommonMapper;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Map;

/**
 * @author wang-hai-cheng
 * @since 2021/12/27 23:10
 */
@Service
public class CommonService extends ServiceImpl<CommonMapper, Object> {
    @Transactional
    public Object operation(Map<String, Object> body) {
        //校验
        check(body);
        //处理数据
        return Context.typeHandle.handler(body);
    }

    private void check(Map<String, Object> body) {
        if (body.get(Constant.VARIABLE_NAME.TYPE) == null) {
            throw MessageException.instance(Constant.Message.ILLEGALITY_REQUEST);
        }
    }
}